Skip to content

Commit

Permalink
Add instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
zzhlogin committed Jan 26, 2024
1 parent fac6ce2 commit 42f6eb9
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def __init__(self, delegate: SpanExporter, generator: MetricAttributeGenerator,
@override
def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult:
modified_spans: Sequence[ReadableSpan] = self._add_metric_attributes(spans)
print("HERE!!!!!!!!!!!!!!-----------------inside AwsMetricAttributesSpanExporter-----------modified_spans:")
print(modified_spans)
return self._delegate.export(modified_spans)

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
from opentelemetry.sdk.trace.sampling import Sampler
from opentelemetry.semconv.resource import ResourceAttributes
from opentelemetry.trace import set_tracer_provider
from opentelemetry.sdk.resources import get_aggregated_resources
from opentelemetry.sdk.extension.aws.resource.eks import AwsEksResourceDetector

OTEL_SMP_ENABLED = "OTEL_SMP_ENABLED"
OTEL_METRIC_EXPORT_INTERVAL = "OTEL_METRIC_EXPORT_INTERVAL"
Expand Down Expand Up @@ -88,7 +90,22 @@ def _initialize_components(auto_instrumentation_version):
# populate version if using auto-instrumentation
if auto_instrumentation_version:
auto_resource[ResourceAttributes.TELEMETRY_AUTO_VERSION] = auto_instrumentation_version
resource = Resource.create(auto_resource)
default_resource = Resource.create(auto_resource)

print("HERE----------default_resource: !!!!!!!!!---------------------")
print(default_resource.to_json)

print("Integrating AwsEksResourceDetector--------------------")

resource=get_aggregated_resources(
[
# AwsEc2ResourceDetector(),
AwsEksResourceDetector(),
]
).merge(default_resource)

print("HERE----------resource: !!!!!!!!!---------------------")
print(resource.to_json)

_init_tracing(
exporters=trace_exporters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ COPY ImageServiceApp/requirements.txt /image-service-app/
COPY ImageServiceApp/aws_opentelemetry_distro-0.0.1-py3-none-any.whl /image-service-app/
COPY ImageServiceApp/opentelemetry_sdk_extension_aws-2.0.1-py3-none-any.whl /image-service-app/

RUN pip install -r requirements.txt && pip install aws_opentelemetry_distro-0.0.1-py3-none-any.whl && pip install opentelemetry_sdk_extension_aws-2.0.1-py3-none-any.whl
RUN pip install -r requirements.txt && pip install aws_opentelemetry_distro-0.0.1-py3-none-any.whl && pip install opentelemetry_sdk_extension_aws-2.0.1-py3-none-any.whl --force-reinstall

# Copy the project code into the container
COPY ImageServiceApp/. /image-service-app/
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ COPY VehicleInventoryApp/requirements.txt /vehicle-inventory-app/
COPY VehicleInventoryApp/aws_opentelemetry_distro-0.0.1-py3-none-any.whl /vehicle-inventory-app/
COPY VehicleInventoryApp/opentelemetry_sdk_extension_aws-2.0.1-py3-none-any.whl /vehicle-inventory-app/

RUN pip install -r requirements.txt && pip install aws_opentelemetry_distro-0.0.1-py3-none-any.whl && pip install opentelemetry_sdk_extension_aws-2.0.1-py3-none-any.whl
RUN pip install -r requirements.txt && pip install aws_opentelemetry_distro-0.0.1-py3-none-any.whl && pip install opentelemetry_sdk_extension_aws-2.0.1-py3-none-any.whl --force-reinstall

# Copy the project code into the container
COPY VehicleInventoryApp/. /vehicle-inventory-app/
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,18 @@ spec:
value: "http://cloudwatch-agent.amazon-cloudwatch:4315"
- name: OTEL_METRICS_EXPORTER
value: "none"
- name: OTEL_TRACES_EXPORTER
value: "console"
- name: OTEL_TRACES_SAMPLER
value: "always_on"
- name: OTEL_PROPAGATORS
value: "tracecontext,baggage,b3,xray"
- name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME
value: "vehicle-inventory-backend-6cdcb68db8-r8zx2 (v1:metadata.name)"
- name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME
value: "(v1:spec.nodeName)"
- name: OTEL_RESOURCE_ATTRIBUTES
value: "k8s.container.name=vehicle-inventory-backend,k8s.deployment.name=vehicle-inventory-backend,k8s.namespace.name=default,k8s.node.name=$(OTEL_RESOURCE_ATTRIBUTES_NODE_NAME),k8s.pod.name=$(OTEL_RESOURCE_ATTRIBUTES_POD_NAME),k8s.replicaset.name=vehicle-inventory-backend-6cdcb68db8,service.version=latest"
imagePullPolicy: Always
ports:
- containerPort: 8001
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,17 @@ spec:
value: "true"
- name: OTEL_METRICS_EXPORTER
value: "none"
- name: OTEL_TRACES_EXPORTER
value: "console"
- name: OTEL_TRACES_SAMPLER
value: "always_on"
- name: OTEL_PROPAGATORS
value: "tracecontext,baggage,b3,xray"
- name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME
value: "image-backend-6f9b6df745-dcnq8 (v1:metadata.name)"
- name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME
value: "(v1:spec.nodeName)"
- name: OTEL_RESOURCE_ATTRIBUTES
value: "k8s.container.name=image-backend,k8s.deployment.name=image-backend,k8s.namespace.name=default,k8s.node.name=$(OTEL_RESOURCE_ATTRIBUTES_NODE_NAME),k8s.pod.name=$(OTEL_RESOURCE_ATTRIBUTES_POD_NAME),k8s.replicaset.name=image-backend-6f9b6df745,service.version=latest"
restartPolicy: Always
status: {}

0 comments on commit 42f6eb9

Please sign in to comment.