This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
forked from opensearch-project/opensearch-migrations
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request opensearch-project#475 from gregschohn/ReplayerIns…
…trumentation Replayer instrumentation
- Loading branch information
Showing
213 changed files
with
6,999 additions
and
1,727 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
15 changes: 15 additions & 0 deletions
15
...ensearch/migrations/trafficcapture/kafkaoffloader/tracing/IRootKafkaOffloaderContext.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,15 @@ | ||
package org.opensearch.migrations.trafficcapture.kafkaoffloader.tracing; | ||
|
||
import org.opensearch.migrations.tracing.IInstrumentConstructor; | ||
import org.opensearch.migrations.tracing.commoncontexts.IConnectionContext; | ||
|
||
public interface IRootKafkaOffloaderContext extends IInstrumentConstructor { | ||
KafkaRecordContext.MetricInstruments getKafkaOffloadingInstruments(); | ||
|
||
default KafkaRecordContext createKafkaRecordContext(IConnectionContext telemetryContext, | ||
String topicNameForTraffic, | ||
String recordId, | ||
int length) { | ||
return new KafkaRecordContext(this, telemetryContext, topicNameForTraffic, recordId, length); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...a/org/opensearch/migrations/trafficcapture/kafkaoffloader/tracing/KafkaRecordContext.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 @@ | ||
package org.opensearch.migrations.trafficcapture.kafkaoffloader.tracing; | ||
|
||
import io.opentelemetry.api.common.AttributeKey; | ||
import io.opentelemetry.api.common.AttributesBuilder; | ||
import io.opentelemetry.api.metrics.Meter; | ||
import lombok.Getter; | ||
import lombok.NonNull; | ||
import org.opensearch.migrations.tracing.BaseNestedSpanContext; | ||
import org.opensearch.migrations.tracing.CommonScopedMetricInstruments; | ||
import org.opensearch.migrations.tracing.IScopedInstrumentationAttributes; | ||
import org.opensearch.migrations.tracing.commoncontexts.IConnectionContext; | ||
|
||
public class KafkaRecordContext extends | ||
BaseNestedSpanContext<IRootKafkaOffloaderContext, IConnectionContext> | ||
implements IScopedInstrumentationAttributes { | ||
public static final String ACTIVITY_NAME = "kafkaCommit"; | ||
|
||
static final AttributeKey<String> TOPIC_ATTR = AttributeKey.stringKey("topic"); | ||
static final AttributeKey<String> RECORD_ID_ATTR = AttributeKey.stringKey("recordId"); | ||
static final AttributeKey<Long> RECORD_SIZE_ATTR = AttributeKey.longKey("recordSize"); | ||
|
||
@Getter | ||
public final String topic; | ||
@Getter | ||
public final String recordId; | ||
|
||
public KafkaRecordContext(IRootKafkaOffloaderContext rootScope, IConnectionContext enclosingScope, | ||
String topic, String recordId, int recordSize) { | ||
super(rootScope, enclosingScope); | ||
this.topic = topic; | ||
this.recordId = recordId; | ||
initializeSpan(); | ||
getCurrentSpan().setAttribute(RECORD_SIZE_ATTR, recordSize); | ||
} | ||
|
||
public static class MetricInstruments extends CommonScopedMetricInstruments { | ||
private MetricInstruments(Meter meter, String activityName) { | ||
super(meter, activityName); | ||
} | ||
} | ||
|
||
public static @NonNull MetricInstruments makeMetrics(Meter meter) { | ||
return new MetricInstruments(meter, ACTIVITY_NAME); | ||
} | ||
|
||
@Override | ||
public @NonNull MetricInstruments getMetrics() { | ||
return getRootInstrumentationScope().getKafkaOffloadingInstruments(); | ||
} | ||
|
||
@Override | ||
public String getActivityName() { return "stream_flush_called"; } | ||
|
||
@Override | ||
public AttributesBuilder fillAttributesForSpansBelow(AttributesBuilder builder) { | ||
return super.fillAttributesForSpansBelow(builder) | ||
.put(TOPIC_ATTR, getTopic()) | ||
.put(RECORD_ID_ATTR, getRecordId()); | ||
} | ||
} |
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.