Skip to content

Commit

Permalink
Merge branch 'upstream-main' into context-storage
Browse files Browse the repository at this point in the history
  • Loading branch information
iRevive committed Dec 31, 2024
2 parents 5cf5a4e + 909be58 commit 5ad342c
Show file tree
Hide file tree
Showing 57 changed files with 2,439 additions and 918 deletions.
44 changes: 22 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ concurrency:

jobs:
build:
name: Build and Test
name: Test
strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-22.04]
scala: [2.13, 3]
java: [temurin@8]
project: [rootJS, rootJVM, rootNative]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
- name: Install sbt
uses: sbt/setup-sbt@v1

- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup sbt
uses: sbt/setup-sbt@v1

- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
Expand All @@ -63,11 +63,11 @@ jobs:
run: sbt githubWorkflowCheck

- name: Check headers and formatting
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest'
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-22.04'
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck

- name: Check scalafix lints
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest'
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-22.04'
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' 'scalafixAll --check'

- name: scalaJSLink
Expand All @@ -82,11 +82,11 @@ jobs:
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' test

- name: Check binary compatibility
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest'
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-22.04'
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' mimaReportBinaryIssues

- name: Generate API documentation
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest'
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-22.04'
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' doc

- name: Make target directories
Expand All @@ -110,18 +110,18 @@ jobs:
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-22.04]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
- name: Install sbt
uses: sbt/setup-sbt@v1

- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup sbt
uses: sbt/setup-sbt@v1

- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
Expand Down Expand Up @@ -224,18 +224,18 @@ jobs:
if: github.event.repository.fork == false && github.event_name != 'pull_request'
strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-22.04]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
- name: Install sbt
uses: sbt/setup-sbt@v1

- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup sbt
uses: sbt/setup-sbt@v1

- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
Expand All @@ -259,7 +259,7 @@ jobs:
name: Validate Steward Config
strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-22.04]
java: [temurin@11]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -284,18 +284,18 @@ jobs:
name: Generate Site
strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-22.04]
java: [temurin@11]
runs-on: ${{ matrix.os }}
steps:
- name: Install sbt
uses: sbt/setup-sbt@v1

- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup sbt
uses: sbt/setup-sbt@v1

- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
Expand Down
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ val MUnitScalaCheckVersion = "1.0.0-M11"
val MUnitCatsEffectVersion = "2.0.0"
val MUnitDisciplineVersion = "2.0.0-M3"
val MUnitScalaCheckEffectVersion = "2.0.0-M2"
val OpenTelemetryVersion = "1.44.1"
val OpenTelemetryInstrumentationVersion = "2.10.0"
val OpenTelemetryVersion = "1.45.0"
val OpenTelemetryInstrumentationVersion = "2.11.0"
val OpenTelemetryInstrumentationAlphaVersion = "2.10.0-alpha"
val OpenTelemetrySemConvVersion = "1.28.0-alpha"
val OpenTelemetrySemConvVersion = "1.29.0-alpha"
val OpenTelemetryProtoVersion = "1.4.0-alpha"
val PekkoStreamVersion = "1.1.2"
val PekkoHttpVersion = "1.1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
{%- endmacro -%}

{%- macro stability(type) -%}
{%- if type == "experimental" -%} Stability.experimental
{%- if type == "development" -%} Stability.development
{%- elif not type -%} Stability.development
{%- elif type == "stable" -%} Stability.stable
{%- else -%} _unknown_stability_type_{{ type }}
{%- endif -%}
Expand All @@ -68,7 +69,11 @@
{%- elif type == "double" -%} {{ input }}
{%- elif type == "boolean" -%} {{ input }}
{%- elif type == "string" -%} "{{ input }}"
{%- else -%} _unknown type_{{ input }}
{%- elif type == "int[]" -%} Seq({{ input | join(', ') }})
{%- elif type == "double[]" -%} Seq({{ input | join(', ') }})
{%- elif type == "boolean[]" -%} Seq({{ input | join(', ') }})
{%- elif type == "string[]" -%} Seq({{ input | map('tojson') | join(', ') }})
{%- else -%} _unknown type_{{ type }}_{{ input }}
{%- endif -%}
{% endmacro %}

Expand Down Expand Up @@ -132,7 +137,7 @@ import org.typelevel.otel4s.metrics._
{%- if required_imports.stable == true %}
import org.typelevel.otel4s.semconv.attributes._
{%- endif %}
{%- if required_imports.experimental == true %}
{%- if required_imports.experimental == true and params.experimental == true %}
import org.typelevel.otel4s.semconv.experimental.attributes._
{%- endif %}

Expand Down Expand Up @@ -161,16 +166,20 @@ object {{ object_name }} {
@deprecated("Use stable `{{ stableRef(metric) }}` instead.", "")
{%- endif %}
object {{ objectName(metric) }} extends MetricSpec {

{%- if params.experimental == true -%}
{%- set metric_attributes = metric.attributes %}
{% else %}
{%- set metric_attributes = metric.attributes | selectattr("stability", "equalto", "stable") | list %}
{% endif %}
val name: String = "{{ metric.metric_name }}"
val description: String = "{{ metric.brief }}"
val unit: String = "{{ metric.unit }}"
val stability: Stability = {{ stability(metric.stability) }}
val attributeSpecs: List[AttributeSpec[_]] = {% if metric.attributes | length > 0 %}AttributeSpecs.specs{% else %}Nil{% endif %}
val attributeSpecs: List[AttributeSpec[_]] = {% if metric_attributes | length > 0 %}AttributeSpecs.specs{% else %}Nil{% endif %}

{% if metric.attributes | length > 0 %}
{% if metric_attributes | length > 0 %}
object AttributeSpecs {
{% for attribute in metric.attributes | sort(attribute='name') %}
{% for attribute in metric_attributes | sort(attribute='name') %}
{{ [attribute.brief, concat_if("\n\n@note\n\n", attribute.note)] | comment(indent=6) | replace('$', "$$")}}
{%- if attribute is deprecated %}
@deprecated("{{ attribute.deprecated }}", "")
Expand All @@ -186,7 +195,7 @@ object {{ object_name }} {
)
{% endfor %}
val specs: List[AttributeSpec[_]] =
List({%- for attribute in metric.attributes | sort(attribute='name') %}
List({%- for attribute in metric_attributes | sort(attribute='name') %}
{{ attribute.name | camel_case }},{% endfor %}
)
}
Expand Down
120 changes: 4 additions & 116 deletions docs/examples/grafana/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,131 +62,19 @@ Use the following `docker-compose.yaml` file:
```yaml
version: '3.7'
services:
otel-collector: # receives application metrics and traces via gRPC or HTTP protocol
image: otel/opentelemetry-collector-contrib
command: [--config=/etc/otel-collector-config.yaml]
volumes:
- "./config/otel-collector-config.yaml:/etc/otel-collector-config.yaml"
ports:
- "8888:8888" # Prometheus metrics exposed by the collector
- "8889:8889" # Prometheus exporter metrics
- "4317:4317" # OTLP gRPC receiver
- "4318:4318" # OTLP http receiver
networks:
- static-network

jaeger: # stores traces received from the OpenTelemetry Collector
image: jaegertracing/all-in-one:latest
volumes:
- "./config/jaeger-ui.json:/etc/jaeger/jaeger-ui.json"
command: --query.ui-config /etc/jaeger/jaeger-ui.json
environment:
- METRICS_STORAGE_TYPE=prometheus
- PROMETHEUS_SERVER_URL=http://prometheus:9090
ports:
- "14250:14250"
- "16685:16685" # GRPC
- "16686:16686" # UI
networks:
- static-network

prometheus: # scrapes metrics from the OpenTelemetry Collector
image: prom/prometheus:latest
volumes:
- "./config/prometheus.yml:/etc/prometheus/prometheus.yml"
ports:
- "9090:9090"
networks:
- static-network

grafana: # queries Jaeger and Prometheus to visualize traces and metrics
image: grafana/grafana-oss
restart: unless-stopped
otel-lgtm:
image: grafana/otel-lgtm
ports:
- "3000:3000"
- "4317:4317"
- "4318:4318"
networks:
- static-network

networks:
static-network:
```
### Configuration files
#### ./config/otel-collector-config.yaml
OpenTelemetry Collector configuration: receivers, exporters, and processing pipelines.
```yml
receivers:
otlp:
protocols: # enable OpenTelemetry Protocol receiver, both gRPC and HTTP
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318

exporters:
otlp/jaeger: # export received traces to Jaeger
endpoint: jaeger:4317
tls:
insecure: true

prometheus: # run Prometheus exporter server on port 8889, so Prometheus can scrape the metrics
endpoint: 0.0.0.0:8889
send_timestamps: true

processors:
batch:
timeout: 10s

service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [otlp/jaeger]
metrics:
receivers: [otlp]
processors: [batch]
exporters: [prometheus]
```
#### ./config/prometheus.yml
Prometheus server configuration: scrape interval and targets.
```yml
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.

scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "prometheus" # scrape prometheus itself to collect the internal metrics (e.g. scrape stats, etc)
static_configs:
- targets: ["localhost:9090"]

- job_name: "otel-collector" # scrape metrics from the OpenTelemetry collector
static_configs:
- targets: ["otel-collector:8889"]
```
#### ./config/jaeger-ui.json
Jaeger configuration: enable [Service Performance Monitor (SPM)](https://www.jaegertracing.io/docs/1.48/spm/).
```json
{
"monitor": {
"menuEnabled": true
},
"dependencies": {
"menuEnabled": true
}
}
```

### Application example
Example service mocking a call to a remote API: here the remote API returns apples or bananas.
Expand Down
Loading

0 comments on commit 5ad342c

Please sign in to comment.