Skip to content
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
120 changes: 120 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: ci

on:
push:
branches: [ main ]
paths-ignore:
- '**.md'
pull_request:
branches: [ main ]
workflow_dispatch:

env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
NUGET_XMLDOC_MODE: skip
TERM: xterm

permissions: {}

jobs:
build-test:
name: ${{ matrix.os-name }}
runs-on: ${{ matrix.runner }}

outputs:
dotnet-sdk-version: ${{ steps.setup-dotnet.outputs.dotnet-version }}

permissions:
attestations: write
contents: write
id-token: write

strategy:
fail-fast: false
matrix:
include:
- os-name: macos
runner: macos-latest
- os-name: linux
runner: ubuntu-latest
- os-name: windows
runner: windows-latest

steps:

- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
filter: 'tree:0'
show-progress: false

- name: Setup .NET SDK
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
id: setup-dotnet

- name: Build
run: dotnet build --configuration Release

- name: Test
run: dotnet test --configuration Release --logger:"GitHubActions;report-warnings=false"

- name: Generate SBOM
uses: anchore/sbom-action@9f7302141466aa6482940f15371237e9d9f4c34a # v0.19.0
with:
artifact-name: build-${{ matrix.os-name }}.spdx.json
output-file: ./artifacts/build.spdx.json
path: ./artifacts/bin
upload-release-assets: ${{ runner.os == 'Windows' }}

- name: Attest artifacts
uses: actions/attest-build-provenance@db473fddc028af60658334401dc6fa3ffd8669fd # v2.3.0
if: |
runner.os == 'Windows' &&
github.event.repository.fork == false &&
(github.ref_name == github.event.repository.default_branch || startsWith(github.ref, 'refs/tags/'))
with:
subject-path: |
./artifacts/bin/Grafana.OpenTelemetry*/release*/Grafana.OpenTelemetry*.dll
./artifacts/package/release/*

- name: Publish NuGet packages
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: packages-${{ matrix.os-name }}
path: ./artifacts/package/release
if-no-files-found: error

validate-packages:
needs: build-test
runs-on: ubuntu-latest
steps:

- name: Download packages
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: packages-windows

- name: Setup .NET SDK
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
with:
dotnet-version: ${{ needs.build-test.outputs.dotnet-sdk-version }}

- name: Validate NuGet packages
shell: pwsh
run: |
dotnet tool install --global dotnet-validate --version 0.0.1-preview.304 --allow-roll-forward
$packages = Get-ChildItem -Filter "*.nupkg" | ForEach-Object { $_.FullName }
$invalidPackages = 0
foreach ($package in $packages) {
dotnet validate package local $package
if ($LASTEXITCODE -ne 0) {
$invalidPackages++
}
}
if ($invalidPackages -gt 0) {
Write-Output "::error::$invalidPackages NuGet package(s) failed validation."
exit 1
}
42 changes: 0 additions & 42 deletions .github/workflows/unit-tests.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
mono_crash.*

# Build results
[Aa]rtifacts/
[Bb]uild/
[Dd]ebug/
[Dd]ebugPublic/
Expand Down
34 changes: 34 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Project>
<PropertyGroup>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<Authors>Grafana Labs</Authors>
<ChecksumAlgorithm>SHA256</ChecksumAlgorithm>
<Company>Grafana Labs</Company>
<ContinuousIntegrationBuild Condition=" '$(CI)' != '' ">true</ContinuousIntegrationBuild>
<Copyright>Copyright (c) Grafana Labs</Copyright>
<Deterministic>true</Deterministic>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<NeutralLanguage>en-US</NeutralLanguage>
<!-- Disable warning about stable packages depending on prerelease packages until all OpenTelemetry dependencies are stable -->
<NoWarn>$(NoWarn);NU5104</NoWarn>
<Nullable>disable</Nullable>
<PackageIcon>Grafana_icon.png</PackageIcon>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://grafana.com/docs/grafana-cloud/monitor-applications/application-observability/</PackageProjectUrl>
<PackageReadmeFile>package-readme.md</PackageReadmeFile>
<PackageReleaseNotes>https://github.com/grafana/grafana-opentelemetry-dotnet/blob/main/CHANGELOG.md</PackageReleaseNotes>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageTags>OpenTelemetry;Grafana;Metrics;Logs;Traces;Observability;Monitoring</PackageTags>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/grafana/grafana-opentelemetry-dotnet</RepositoryUrl>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<UseArtifactsOutput>true</UseArtifactsOutput>
</PropertyGroup>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)/internal/img/$(PackageIcon)" Pack="true" PackagePath="" />
<None Include="$(MsBuildThisFileDirectory)/$(PackageReadmeFile)" Pack="true" PackagePath="" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ To engage with the Grafana Application Observability community:
* [File an issue][issues] for bugs, issues, and feature suggestions.

[app-o11y]: https://grafana.com/docs/grafana-cloud/monitor-applications/application-observability/
[ci-badge]: https://github.com/grafana/grafana-opentelemetry-dotnet/actions/workflows/unit-tests.yml/badge.svg?branch=main
[ci-status]: https://github.com/grafana/grafana-opentelemetry-dotnet/actions/workflows/unit-tests.yml
[ci-badge]: https://github.com/grafana/grafana-opentelemetry-dotnet/actions/workflows/ci.yml/badge.svg?branch=main
[ci-status]: https://github.com/grafana/grafana-opentelemetry-dotnet/actions/workflows/ci.yml
[discussions]: https://github.com/grafana/grafana-opentelemetry-dotnet/discussions
[issues]: https://github.com/grafana/grafana-opentelemetry-dotnet/issues/new
[oats-badge]: https://github.com/grafana/grafana-opentelemetry-dotnet/actions/workflows/oats.yml/badge.svg?branch=main
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"sdk": {
"rollForward": "latestFeature",
"version": "8.0.101",
"version": "8.0.410",
"allowPrerelease": false
}
}
63 changes: 63 additions & 0 deletions package-readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Grafana OpenTelemetry distribution for .NET

<!-- markdown-link-check-disable -->
[![NuGet][package-badge-version]][package-download]
[![SDK][otel-badge]][otel]
[![Slack][slack-badge]][slack-channel]
<!-- markdown-link-check-enable -->

## About

This is a pre-configured and pre-packaged bundle of [OpenTelemetry .NET components][otel-contrib],
optimized for [Grafana Cloud Application Observability][app-o11y].

It requires only minimal setup and configuration and makes it very easy to emit
OpenTelemetry metrics, logs, and traces from your .NET application.

## Getting Started

### Step 1: Install package

For installing the distribution with the full set of dependencies, add a
reference to the [`Grafana.OpenTelemetry`][package] package to your project.

```sh
dotnet add package Grafana.OpenTelemetry
```

### Step 2: Enable the Grafana distribution at application startup

The `UseGrafana` extension method on the `TracerProviderBuilder` or the
`MetricProviderBuilder` can be used to set up the Grafana distribution. By
default, telemetry data will be sent to Grafana Alloy or an OpenTelemetry collector
that runs locally and listens to default OTLP ports.

```csharp
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.UseGrafana()
.Build();
```

Alternatively, you can send telemetry data directly to Grafana Cloud without
involving an agent or collector. This can be configured via the environment
variables `OTEL_EXPORTER_OTLP_PROTOCOL`, `OTEL_EXPORTER_OTLP_ENDPOINT`, and
`OTEL_EXPORTER_OTLP_HEADERS`.

For details on how to obtain those values, refer to
[Send data to the Grafana Cloud OTLP endpoint: Quickstart architecture][push-oltp].

## Documentation

For detailed documentation and setup instructions, refer to [our documentation][docs].

[app-o11y]: https://grafana.com/docs/grafana-cloud/monitor-applications/application-observability/
[docs]: https://github.com/grafana/grafana-opentelemetry-dotnet/tree/main/docs
[otel]: https://github.com/open-telemetry/opentelemetry-dotnet
[otel-badge]: https://img.shields.io/badge/OTel--SDK-1.9.0-blue?style=flat&logo=opentelemetry
[otel-contrib]: http://github.com/open-telemetry/opentelemetry-dotnet-contrib
[package]: https://www.nuget.org/packages/Grafana.OpenTelemetry
[package-badge-version]: https://img.shields.io/nuget/v/Grafana.OpenTelemetry?logo=nuget&label=NuGet&color=blue
[package-download]: https://www.nuget.org/profiles/Grafana
[push-oltp]: https://grafana.com/docs/grafana-cloud/send-data/otlp/send-data-otlp/#quickstart-architecture
[slack-badge]: https://img.shields.io/badge/%20Slack-%23app--o11y-brightgreen.svg?logo=slack
[slack-channel]: https://grafana.slack.com/archives/C05E87XRK3J
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;netstandard2.0;net462</TargetFrameworks>
<Nullable>disable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>

<!-- NuGet packaging properties -->
<Description>Minimal Grafana distribution of OpenTelemetry .NET</Description>
<Authors>Grafana Labs</Authors>
<Copyright>Copyright (c) Grafana Labs</Copyright>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageTags>OpenTelemetry;Grafana;Metrics;Logs;Traces;Observability;Monitoring</PackageTags>
<PackageIcon>Grafana_icon.png</PackageIcon>
<PackageReleaseNotes>https://github.com/grafana/grafana-opentelemetry-dotnet/blob/main/CHANGELOG.md</PackageReleaseNotes>
<PackageProjectUrl>https://grafana.com/docs/grafana-cloud/monitor-applications/application-observability/</PackageProjectUrl>
<RepositoryUrl>https://github.com/grafana/grafana-opentelemetry-dotnet</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<TargetFrameworks>net8.0;netstandard2.0;net462</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
<PackageReference Include="System.Text.Json" Version="8.0.5" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))" />
<PackageReference Include="MinVer" Version="4.3.0">
<PackageReference Include="MinVer" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down Expand Up @@ -52,18 +40,14 @@
<PackageReference Include="OpenTelemetry.Resources.ProcessRuntime" Version="0.1.0-beta.2" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
<PackageReference Include="OpenTelemetry.Resources.Container" Version="1.0.0-beta.9" />
</ItemGroup>

<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>Grafana.OpenTelemetry.Tests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>

<ItemGroup>
<None Include="../../internal/img/Grafana_icon.png" Pack="true" Visible="false" PackagePath="" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="OpenTelemetry.Resources.Container" Version="1.0.0-beta.9" />
</ItemGroup>

</Project>
Loading
Loading