-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Creating okhttp instrumentation subprojects * Added http span name test * Updating tests * Creating http span interceptors * Creating HttpSpanNameInterceptor * Renaming http spans * Setting http span interceptor in builder * Validating http known methods * Adding tests * Created okhttp test project * Added okhttp simple test * Creating okhttp bytebuddy project * Adding okhttp library bytebuddy plugin symbols * Configuring OkHttp3Singletons * Substituting local bytebuddy dependencies * Moving bytebuddy plugin definitions * Flushing spans for androidTests * Validating successful okhttp sync requests * Adding tests * Updating notice files * Adding build variant listener * Updating instrumentation plugins * Attaching bytebuddy plugins using the ByteBuddyDependencyAttacher * Updating tests * Bumping version * Creating android_tests.sh * Running android tests as part of the CI checks * Adding animalsniffer checks * Ignoring animalsniffer unnecessary warnings * Adding header * Updating licence header tools * Adding internal notice spotless step * Ensuring internal comment is only added to production code * Using InternalNoticeStep singleton * Renaming tests.sh * Updating ci job name * Removing internal notice generator for now * Simplifying disk config * Adding resource interceptor * Adding tests * Updating sample app * Updating description * Clean up * Updating sample app * Converting sample app gradle files to kts * Clean up * Reorganizing sample app packages * Adding okhttp instrumentation to sample app * Adding logs * Adding logs * Updating processing times * Adding context propagator * Adding notice files * Adding instrumentations to sample app
- Loading branch information
1 parent
c2bbe1c
commit d3a7c8e
Showing
67 changed files
with
796 additions
and
302 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
18 changes: 18 additions & 0 deletions
18
android-api/src/main/java/co/elastic/otel/android/api/clock/ClockProvider.kt
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
18 changes: 18 additions & 0 deletions
18
android-api/src/main/java/co/elastic/otel/android/api/flusher/LogRecordFlusher.kt
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
18 changes: 18 additions & 0 deletions
18
android-api/src/main/java/co/elastic/otel/android/api/flusher/MetricFlusher.kt
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
18 changes: 18 additions & 0 deletions
18
android-api/src/main/java/co/elastic/otel/android/api/flusher/SpanFlusher.kt
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
18 changes: 18 additions & 0 deletions
18
...plugin/src/main/java/co/elastic/otel/android/plugin/extensions/BytecodeInstrumentation.kt
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
18 changes: 18 additions & 0 deletions
18
...oid-plugin/src/main/java/co/elastic/otel/android/plugin/extensions/ElasticApmExtension.kt
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
18 changes: 18 additions & 0 deletions
18
android-plugin/src/main/java/co/elastic/otel/android/plugin/internal/BuildVariantListener.kt
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
18 changes: 18 additions & 0 deletions
18
...ugin/src/main/java/co/elastic/otel/android/plugin/internal/ByteBuddyDependencyAttacher.kt
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
18 changes: 18 additions & 0 deletions
18
...oid-plugin/src/main/java/co/elastic/otel/android/plugin/internal/InstrumentationPlugin.kt
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
77 changes: 77 additions & 0 deletions
77
android-sdk/src/main/java/co/elastic/otel/android/extensions/ElasticOtelAgentExtensions.kt
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,77 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package co.elastic.otel.android.extensions | ||
|
||
import co.elastic.otel.android.api.ElasticOtelAgent | ||
import io.opentelemetry.api.common.Attributes | ||
import io.opentelemetry.api.logs.Severity | ||
import io.opentelemetry.api.trace.Span | ||
import io.opentelemetry.api.trace.SpanKind | ||
import io.opentelemetry.api.trace.StatusCode | ||
import io.opentelemetry.context.Context | ||
import io.opentelemetry.context.Scope | ||
import java.time.Instant | ||
|
||
private const val SCOPE_NAME = "ElasticAgentExtension" | ||
|
||
fun ElasticOtelAgent.log( | ||
body: String, | ||
severity: Severity? = null, | ||
severityText: String? = null, | ||
attributes: Attributes? = null, | ||
context: Context? = null, | ||
observedTimestamp: Instant? = null, | ||
timestamp: Instant? = null | ||
) { | ||
val logger = getOpenTelemetry().logsBridge.get(SCOPE_NAME).logRecordBuilder() | ||
.setBody(body) | ||
severity?.let { logger.setSeverity(it) } | ||
severityText?.let { logger.setSeverityText(it) } | ||
attributes?.let { logger.setAllAttributes(it) } | ||
context?.let { logger.setContext(it) } | ||
observedTimestamp?.let { logger.setObservedTimestamp(it) } | ||
timestamp?.let { logger.setTimestamp(it) } | ||
logger.emit() | ||
} | ||
|
||
fun ElasticOtelAgent.span( | ||
name: String, | ||
attributes: Attributes? = null, | ||
kind: SpanKind? = null, | ||
parentContext: Context? = null, | ||
makeCurrent: Boolean = true, | ||
body: (Span) -> Unit | ||
) { | ||
val builder = getOpenTelemetry().getTracer(SCOPE_NAME).spanBuilder(name) | ||
attributes?.let { builder.setAllAttributes(it) } | ||
kind?.let { builder.setSpanKind(it) } | ||
parentContext?.let { builder.setParent(it) } | ||
|
||
val span = builder.startSpan() | ||
val scope: Scope? = if (makeCurrent) span.makeCurrent() else null | ||
try { | ||
body(span) | ||
} catch (e: Throwable) { | ||
span.setStatus(StatusCode.ERROR) | ||
span.recordException(e) | ||
} finally { | ||
scope?.close() | ||
span.end() | ||
} | ||
} |
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.