-
Notifications
You must be signed in to change notification settings - Fork 10
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
Trying to connect elastic agent using kotlin (native android) with flutter using channel and send spans manually #336
Comments
Please bear in mind that the agent is meant to be used by native Android apps, however, I guess in theory it could be added to the Android project inside a Flutter project, though it hasn't been tested and we don't guarantee that it will work well in non-android native projects. Having said that, after making sure that your Android project has the agent properly set up, the way to send telemetry manually is as you've pointed out in your example, i.e: val tracer = GlobalOpenTelemetry.getTracer(instrumentationScopeName) // Getting a tracer
val span = tracer.spanBuilder("Span name").startSpan() // Starting a span
// Code traced by the span.
span.end() // Ending a span Bear in mind that spans are first collected and sent in a batch, so you should give it a couple of seconds after calling If you want to create a child span inside the first span and see them nested later in Kibana, you should make sure to set the "parent span" context as the current one, like so: val tracer = GlobalOpenTelemetry.getTracer(instrumentationScopeName)
val parentSpan = tracer.spanBuilder("Parent span name").startSpan()
val parentSpanScope = parentSpan.makeCurrent()
val childSpan = tracer.spanBuilder("Child span name").startSpan()
childSpan.end()
parentSpanScope.close()
parentSpan.end() For more details you should take a look at the official OTel Java docs on creating spans: https://opentelemetry.io/docs/languages/java/instrumentation/#create-spans |
I have tried this solution but didn't work as expect. is there a plan to add support to flutter |
Flutter isn't currently on our roadmap, though it's also not impossible for it to become a priority in the future, though as of now, we're focusing on native Android and iOS agents. When you mentioned that it didn't work as you expected, does it mean that you got some spans in Kibana that didn't have the data you expected? Or does it mean that you didn't get any telemetry in Kibana at all? |
spans didn't recorded from flutter application to native |
I am trying to connect elastic from flutter to native android using kotlin and log API by sending spans as this example
what is the best way to send spans manually from android native code
The text was updated successfully, but these errors were encountered: