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

feat: add opentelemetry support (but no instrumentation yet) #667

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
"datasourceTemplate": "github-tags",
"packageNameTemplate": "aws/aws-cli",
"autoReplaceStringTemplate": "{{depName}} = \"ref:{{newVersion}}\""
},
{
"customType": "regex",
"fileMatch": ["\\.ts$"],
"matchStrings": [
Copy link
Contributor

Choose a reason for hiding this comment

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

Mitä tämä tekee? Onko vaikutusta e2e:hen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tätä käytetään kohdassa https://github.com/Opetushallitus/koto-rekisteri/pull/667/files#diff-c2bc29222885a24f378713b86c792524289f18d9a645a40b8490345da9d09f82R141 - kerrotaan renovatelle että seuraavalla rivillä on riippuvuus ja miten sen voi parsia ja päivittää. Ei vaikuta e2e:hen ellei sinne lisää samantyylistä kommenttia.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

...ja tuo tosiaan tarvitaan koska tämä otel-sidecar-kontti on uusi tässä PR:ssä ja sen versio määritellään meidän CDK-koodissa.

Copy link
Contributor

Choose a reason for hiding this comment

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

aa, kätevää 👍

"renovate: datasource=(?<datasource>.+?)\\s+\"(?<depName>\\S+):(?<currentValue>\\S+)\""
],
"versioningTemplate": "semver"
}
]
}
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,18 @@ services:
PGUSER: kitu
ports:
- "127.0.0.1:5432:5432"

collector:
image: otel/opentelemetry-collector:0.114.0
command: ["--config=/etc/otel-collector-config.yml"]
volumes:
- ./otel-config.yml:/etc/otel-collector-config.yml
ports:
- "4318:4318" # OTLP HTTP
depends_on:
- jaeger

jaeger:
image: jaegertracing/all-in-one:latest
ports:
- "16686:16686" # UI
13 changes: 13 additions & 0 deletions infra/lib/service-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { DatabaseCluster } from "aws-cdk-lib/aws-rds"
import { HostedZone } from "aws-cdk-lib/aws-route53"
import { ITopic } from "aws-cdk-lib/aws-sns"
import { Construct } from "constructs"
import { ManagedPolicy } from "aws-cdk-lib/aws-iam"

export interface ServiceStackProps extends StackProps {
auditLogGroup: ILogGroup
Expand Down Expand Up @@ -135,13 +136,25 @@ export class ServiceStack extends Stack {
sslPolicy: SslPolicy.RECOMMENDED_TLS,
})

this.service.taskDefinition.addContainer("AwsOtelCollector", {
image: ContainerImage.fromRegistry(
// renovate: datasource=docker
"public.ecr.aws/aws-observability/aws-otel-collector:v0.41.1",
),
})

this.service.targetGroup.configureHealthCheck({
...this.service.targetGroup.healthCheck,
path: "/actuator/health",
})

props.auditLogGroup.grantWrite(this.service.service.taskDefinition.taskRole)

// Ref: https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AWSXrayWriteOnlyAccess.html
this.service.taskDefinition.taskRole.addManagedPolicy(
ManagedPolicy.fromAwsManagedPolicyName("AWSXrayWriteOnlyAccess"),
)

this.service.service
.metricCpuUtilization()
.createAlarm(this, "CpuUtilization", {
Expand Down
32 changes: 32 additions & 0 deletions otel-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
receivers:
otlp:
protocols:
grpc:
http:
endpoint: 0.0.0.0:4318

processors:
batch:

extensions:
health_check:

exporters:
debug:
otlphttp/jaeger:
endpoint: http://jaeger:4318

service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [debug, otlphttp/jaeger]
metrics:
receivers: [otlp]
processors: [batch]
exporters: [debug]
logs:
receivers: [otlp]
processors: [batch]
exporters: [debug]
20 changes: 20 additions & 0 deletions server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-instrumentation-bom</artifactId>
<version>2.10.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -180,6 +187,14 @@
<artifactId>db-scheduler-log-spring-boot-starter</artifactId>
<version>0.7.0</version>
</dependency>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
Expand All @@ -194,6 +209,11 @@
<artifactId>opentelemetry-semconv-incubating</artifactId>
<version>${opentelemetry-semconv.version}</version>
</dependency>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-aws-sdk-2.2-autoconfigure</artifactId>
<version>2.10.0-alpha</version>
</dependency>
<dependency>
<groupId>no.bekk.db-scheduler-ui</groupId>
<artifactId>db-scheduler-ui-starter</artifactId>
Expand Down
2 changes: 2 additions & 0 deletions server/src/main/resources/application-prod.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ kitu.yki.scheduling.enabled=true
kitu.yki.baseUrl=https://yki.jyu.fi/yki-sp/oph/
kitu.yki.scheduling.import.schedule=DAILY|03:00
kitu.yki.scheduling.importArvioijat.schedule=DAILY|03:00

otel.resource.providers.aws.enabled=true
2 changes: 2 additions & 0 deletions server/src/main/resources/application-qa.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ kitu.yki.scheduling.enabled=true
kitu.yki.scheduling.import.schedule=DAILY|03:00
kitu.yki.scheduling.importArvioijat.schedule=DAILY|03:00
kitu.yki.baseUrl=https://yki-test.cc.jyu.fi/yki-sp/oph/

otel.resource.providers.aws.enabled=true
2 changes: 2 additions & 0 deletions server/src/main/resources/application-untuva.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ kitu.yki.scheduling.enabled=true
kitu.yki.scheduling.import.schedule=DAILY|03:00
kitu.yki.scheduling.importArvioijat.schedule=DAILY|03:00
kitu.yki.baseUrl=https://yki-test.cc.jyu.fi/yki-sp/oph/

otel.resource.providers.aws.enabled=true
1 change: 1 addition & 0 deletions server/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ spring.mustache.suffix=.mustache

logging.structured.format.console=ecs
logging.structured.format.file=ecs
otel.traces.exporter=otlp

# Uncomment this to debug authentication/authorization issues.
# Ref: https://docs.spring.io/spring-security/reference/servlet/architecture.html#servlet-logging
Expand Down
1 change: 1 addition & 0 deletions server/src/test/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ kitu.yki.password=

logging.structured.format.console=ecs
logging.structured.format.file=ecs
otel.traces.exporter=otlp
Loading