Skip to content
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

Updating dependencies regarding issues 721 715 714 691 #846

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions load-generator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ dependencies {

implementation "io.grpc:grpc-netty-shaded:1.47.0"

implementation platform("io.opentelemetry:opentelemetry-bom:1.12.0")
implementation platform("io.opentelemetry:opentelemetry-bom:1.18.0")
implementation "io.opentelemetry:opentelemetry-api"
implementation "io.opentelemetry:opentelemetry-sdk-metrics:1.4.1-alpha"
implementation "io.opentelemetry:opentelemetry-exporter-otlp:1.10.0"
implementation "io.opentelemetry:opentelemetry-exporter-otlp-metrics:1.4.1-alpha"
implementation "io.opentelemetry:opentelemetry-sdk-extension-aws"
implementation "io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:1.4.1-alpha"
implementation "io.opentelemetry:opentelemetry-sdk"
implementation "io.opentelemetry:opentelemetry-exporter-otlp"

implementation "io.opentelemetry:opentelemetry-semconv:1.18.0-alpha"
implementation "io.opentelemetry:opentelemetry-sdk-extension-aws"
implementation "com.amazonaws:aws-xray-recorder-sdk-core:2.11.2"
implementation "com.amazonaws:aws-xray-recorder-sdk-aws-sdk:2.11.2"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,29 @@
package com.amazon.opentelemetry.load.generator.emitter;

import com.amazon.opentelemetry.load.generator.model.Parameter;
import io.grpc.ManagedChannelBuilder;
import io.opentelemetry.api.metrics.GlobalMeterProvider;
import io.opentelemetry.api.metrics.common.Labels;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.metrics.LongCounter;
import io.opentelemetry.api.metrics.LongValueRecorder;
import io.opentelemetry.api.metrics.Meter;

import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.metrics.export.IntervalMetricReader;
import io.opentelemetry.sdk.metrics.export.MetricExporter;
import java.util.Collections;
import io.opentelemetry.sdk.metrics.export.PeriodicMetricReader;
import io.opentelemetry.sdk.resources.Resource;
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;

import java.util.concurrent.ThreadLocalRandom;
import java.time.Duration;

public class OtlpMetricEmitter extends MetricEmitter {

private final static String API_NAME = "loadTest";
private final static Attributes METRIC_ATTRIBUTES = Attributes.of(AttributeKey.stringKey(DIMENSION_API_NAME), API_NAME,
AttributeKey.stringKey(DIMENSION_STATUS_CODE), "200");
LongCounter apiBytesSentCounter;
LongValueRecorder apiLatencyRecorder;
Long apiLatency;

public OtlpMetricEmitter(Parameter param) {
super();
Expand All @@ -47,43 +53,46 @@ public void emitDataLoad() throws Exception {

@Override
public void nextDataPoint() {
apiLatencyRecorder.record(200, Labels
.of(DIMENSION_API_NAME, API_NAME, DIMENSION_STATUS_CODE, "200"));

apiBytesSentCounter
.add(100, Labels.of(DIMENSION_API_NAME, API_NAME, DIMENSION_STATUS_CODE, "200"));
.add(10, METRIC_ATTRIBUTES);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.add(10, METRIC_ATTRIBUTES);
.add(10, METRIC_ATTRIBUTES);

Why did you change the value being added? Will this affect the tests in any way?

mutateApiLatency();
}

@Override
public void setupProvider() {
MetricExporter metricExporter =
OtlpGrpcMetricExporter.builder()
.setChannel(
ManagedChannelBuilder.forTarget(param.getEndpoint()).usePlaintext().build())
.build();

IntervalMetricReader.builder()
.setMetricProducers(
Collections.singleton(SdkMeterProvider.builder().buildAndRegisterGlobal()))
.setExportIntervalMillis(param.getFlushInterval())
.setMetricExporter(metricExporter)
.build();

Meter meter = GlobalMeterProvider.getMeter("aws-otel-load-generator-metric", "0.1.0");


apiBytesSentCounter = meter
.longCounterBuilder(API_COUNTER_METRIC)
.setDescription("API request load sent in bytes")
.setUnit("one")
.build();

apiLatencyRecorder =
meter
.longValueRecorderBuilder(API_LATENCY_METRIC)
Resource resource = Resource.getDefault().merge(
Resource.create(Attributes.of(ResourceAttributes.SERVICE_NAME, "load-generator")));

OpenTelemetrySdk.builder().setMeterProvider(
SdkMeterProvider.builder()
.registerMetricReader(
PeriodicMetricReader.builder(OtlpGrpcMetricExporter.builder().setEndpoint("http://" + param.getEndpoint()).build())
.setInterval(Duration.ofMillis(param.getFlushInterval())).build())
.setResource(resource)

.build())
.buildAndRegisterGlobal();

Meter meter =
GlobalOpenTelemetry.meterBuilder("aws-otel-load-generator-metric")
.setInstrumentationVersion("0.1.0")
.build();

apiBytesSentCounter =
meter.counterBuilder(API_COUNTER_METRIC)
.setDescription("API request load sent in bytes")
.setUnit("one")
.build();

meter.gaugeBuilder(API_LATENCY_METRIC)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can use a histogram to record latency instead of a gauge: https://aws-otel.github.io/docs/getting-started/java-sdk/trace-manual-instr#creating-metrics

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. as discussed keeping Gauge for now.

.setDescription("API latency time")
.setUnit("ms")
.build();
.ofLongs()
.buildWithCallback(measurement -> measurement.record(
apiLatency, METRIC_ATTRIBUTES));
}

}
private void mutateApiLatency() {
this.apiLatency = ThreadLocalRandom.current().nextLong(-100,100);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,22 @@

package com.amazon.opentelemetry.load.generator.emitter;

import com.amazon.opentelemetry.load.generator.factory.AwsTracerConfigurer;
import com.amazon.opentelemetry.load.generator.model.Parameter;
import io.grpc.ManagedChannelBuilder;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.api.trace.TracerProvider;
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
import io.opentelemetry.sdk.trace.export.BatchSpanProcessor;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.Tracer;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.extension.aws.trace.AwsXrayIdGenerator;
import io.opentelemetry.sdk.resources.Resource;
import io.opentelemetry.sdk.trace.SdkTracerProvider;
import io.opentelemetry.sdk.trace.SdkTracerProviderBuilder;
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;

import java.time.Duration;
import java.util.UUID;

Expand All @@ -46,20 +51,24 @@ public void emitDataLoad() throws Exception {

@Override
public void setupProvider() throws Exception {
OtlpGrpcSpanExporter spanExporter = OtlpGrpcSpanExporter.builder()
.setChannel(
ManagedChannelBuilder.forTarget(param.getEndpoint()).usePlaintext().build())
.setTimeout(Duration.ofMillis(10))
.build();

SdkTracerProviderBuilder builder = SdkTracerProvider.builder();
new AwsTracerConfigurer().configure(builder);
builder.addSpanProcessor(SimpleSpanProcessor.create(spanExporter));
TracerProvider tracerProvider = builder.build();
Resource resource = Resource.getDefault().merge(
Resource.create(Attributes.of(ResourceAttributes.SERVICE_NAME, "load-generator")));

tracer =
tracerProvider.get("aws-otel-load-generator-trace", "semver:0.1.0");
OpenTelemetrySdk.builder()
.setTracerProvider(
SdkTracerProvider.builder()
.addSpanProcessor(
BatchSpanProcessor.builder(OtlpGrpcSpanExporter.getDefault()).build())
.setIdGenerator(AwsXrayIdGenerator.getInstance())
.setResource(resource)
.build())
.buildAndRegisterGlobal();

tracer =
GlobalOpenTelemetry.tracerBuilder("aws-otel-load-generator-trace")
.setInstrumentationVersion("semver:0.1.0")
.build();
}

@Override
Expand Down

This file was deleted.