-
Notifications
You must be signed in to change notification settings - Fork 882
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use micrometer1-shim in micrometer javaagent instrumentation, depreca… (
#5820) * Use micrometer1-shim in micrometer javaagent instrumentation, deprecate micrometer library instrumentation * fix actuator instrumentation
- Loading branch information
Mateusz Rzeszutek
authored
Apr 15, 2022
1 parent
4879ced
commit b19e95b
Showing
37 changed files
with
1,971 additions
and
68 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
60 changes: 60 additions & 0 deletions
60
.../main/java/io/opentelemetry/javaagent/instrumentation/micrometer/v1_5/TimeUnitParser.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,60 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.micrometer.v1_5; | ||
|
||
import static java.util.logging.Level.WARNING; | ||
|
||
import io.opentelemetry.micrometer1shim.OpenTelemetryMeterRegistry; | ||
import java.util.Locale; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.logging.Logger; | ||
import javax.annotation.Nullable; | ||
|
||
final class TimeUnitParser { | ||
|
||
private static final Logger logger = Logger.getLogger(OpenTelemetryMeterRegistry.class.getName()); | ||
|
||
static TimeUnit parseConfigValue(@Nullable String value) { | ||
if (value == null) { | ||
return TimeUnit.MILLISECONDS; | ||
} | ||
// short names are UCUM names | ||
// long names are just TimeUnit values lowercased | ||
switch (value.toLowerCase(Locale.ROOT)) { | ||
case "ns": | ||
case "nanoseconds": | ||
return TimeUnit.NANOSECONDS; | ||
case "us": | ||
case "microseconds": | ||
return TimeUnit.MICROSECONDS; | ||
case "ms": | ||
case "milliseconds": | ||
return TimeUnit.MILLISECONDS; | ||
case "s": | ||
case "seconds": | ||
return TimeUnit.SECONDS; | ||
case "min": | ||
case "minutes": | ||
return TimeUnit.MINUTES; | ||
case "h": | ||
case "hours": | ||
return TimeUnit.HOURS; | ||
case "d": | ||
case "days": | ||
return TimeUnit.DAYS; | ||
default: | ||
if (logger.isLoggable(WARNING)) { | ||
logger.log( | ||
WARNING, | ||
"Invalid base time unit: '{0}'; using 'ms' as the base time unit instead", | ||
value); | ||
} | ||
return TimeUnit.MILLISECONDS; | ||
} | ||
} | ||
|
||
private TimeUnitParser() {} | ||
} |
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.