-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sdk-common: add TelemetryResourceDetector
#721
Conversation
def detect: F[Option[TelemetryResource]] = Sync[F].delay { | ||
val host = Keys.Host(OS.hostname()) | ||
val arch = Keys.Arch(normalizeArch(OS.arch())) | ||
|
||
Some(TelemetryResource(Attributes(host, arch), Some(SchemaUrls.Current))) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JS implementation.
for { | ||
hostOpt <- Sync[F] | ||
.blocking(InetAddress.getLocalHost.getHostName) | ||
.redeem(_ => None, Some(_)) | ||
|
||
archOpt <- Sync[F].delay(sys.props.get("os.arch")) | ||
} yield { | ||
val host = hostOpt.map(Keys.Host(_)) | ||
val arch = archOpt.map(Keys.Arch(_)) | ||
val attributes = host.to(Attributes) ++ arch.to(Attributes) | ||
Option.when(attributes.nonEmpty)( | ||
TelemetryResource(attributes, Some(SchemaUrls.Current)) | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JVM implementation.
for { | ||
hostOpt <- Sync[F].delay(detectHost).handleError(_ => None) | ||
archOpt <- Sync[F].delay(sys.props.get("os.arch")) | ||
} yield { | ||
val host = hostOpt.map(Keys.Host(_)) | ||
val arch = archOpt.map(Keys.Arch(_)) | ||
val attributes = host.to(Attributes) ++ arch.to(Attributes) | ||
Option.when(attributes.nonEmpty)( | ||
TelemetryResource(attributes, Some(SchemaUrls.Current)) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scala Native implementation.
39069a1
to
cd57fdc
Compare
cd57fdc
to
08bfc85
Compare
We need
TelemetryResourceDetector
to build environment-awareTelemetryResource
for our Scala SDK.Some context: #615.