forked from HSLdevcom/OpenTripPlanner
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Generalize request tags in OTP, remove dependency to Microm…
…eter API
- Loading branch information
Showing
13 changed files
with
124 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/java/org/opentripplanner/routing/api/request/Tags.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.opentripplanner.routing.api.request; | ||
|
||
import java.io.Serial; | ||
import java.io.Serializable; | ||
import java.util.Collection; | ||
import java.util.Set; | ||
|
||
|
||
/** | ||
* A collection of request tags. The intended use of tags are for cross-cutting | ||
* concerns like performance timing, debugging and logging. Currently, we only use tags for | ||
* performance timing; Hence only one getter method {@code #getTimingTags}. | ||
*/ | ||
public class Tags implements Serializable { | ||
@Serial | ||
private static final long serialVersionUID = 1L; | ||
|
||
/** We only need one set of tags since we support timingTags only */ | ||
private final Set<String> tags; | ||
|
||
private Tags(Collection<String> tags) { | ||
this.tags = tags == null ? Set.of() :Set.copyOf(tags); | ||
} | ||
|
||
public static Tags of() { | ||
return new Tags(null); | ||
} | ||
|
||
public static Tags of(Collection<String> tags) { | ||
return new Tags(tags); | ||
} | ||
|
||
/** Currently all tags are used as Micrometer timing tags */ | ||
public Set<String> getTimingTags() { | ||
return tags; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.join(", ", tags); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/org/opentripplanner/routing/framework/MicrometerUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.opentripplanner.routing.framework; | ||
|
||
import io.micrometer.core.instrument.Tag; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
public class MicrometerUtils { | ||
public static List<Tag> mapTimingTags(Collection<String> timingTags) { | ||
return List.of(Tag.of("tags", String.join(" ", timingTags))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.