Skip to content

Commit

Permalink
.NET support for musl-based containers (#1987)
Browse files Browse the repository at this point in the history
  • Loading branch information
edeNFed authored Dec 17, 2024
1 parent 1433f99 commit 01cef4b
Show file tree
Hide file tree
Showing 38 changed files with 708 additions and 41 deletions.
5 changes: 5 additions & 0 deletions api/config/crd/bases/odigos.io_instrumentationconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,11 @@ spec:
- unknown
- ignored
type: string
libCType:
enum:
- glibc
- musl
type: string
otherAgent:
properties:
name:
Expand Down
5 changes: 5 additions & 0 deletions api/config/crd/bases/odigos.io_instrumentedapplications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ spec:
- unknown
- ignored
type: string
libCType:
enum:
- glibc
- musl
type: string
otherAgent:
properties:
name:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/odigos/v1alpha1/instrumentedapplication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type RuntimeDetailsByContainer struct {
RuntimeVersion string `json:"runtimeVersion,omitempty"`
EnvVars []EnvVar `json:"envVars,omitempty"`
OtherAgent *OtherAgent `json:"otherAgent,omitempty"`
LibCType *common.LibCType `json:"libCType,omitempty"`
}

// +kubebuilder:object:generate=true
Expand Down
5 changes: 5 additions & 0 deletions api/odigos/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 17 additions & 4 deletions common/instrumentationdevice.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,31 @@ const OdigosResourceNamespace = "instrumentation.odigos.io"
// the native Java SDK will be named "java-native-community".
// the ebpf Java enterprise sdk will be named "java-ebpf-enterprise".

func InstrumentationPluginName(language ProgrammingLanguage, otelSdk OtelSdk) string {
return string(language) + "-" + string(otelSdk.SdkType) + "-" + string(otelSdk.SdkTier)
func InstrumentationPluginName(language ProgrammingLanguage, otelSdk OtelSdk, libc *LibCType) string {
result := string(language) + "-" + string(otelSdk.SdkType) + "-" + string(otelSdk.SdkTier)

// If musl libc type recorded - we use different plugin name
if libc != nil && *libc == Musl {
result = "musl-" + result
}

return result
}

func InstrumentationPluginNameToComponents(pluginName string) (ProgrammingLanguage, OtelSdk) {
components := strings.Split(pluginName, "-")
if len(components) > 3 {
// This is a musl libc plugin
pluginName = strings.Join(components[1:], "-")
components = strings.Split(pluginName, "-")
}

otelSdk := OtelSdk{SdkType: OtelSdkType(components[1]), SdkTier: OtelSdkTier(components[2])}
return ProgrammingLanguage(components[0]), otelSdk
}

func InstrumentationDeviceName(language ProgrammingLanguage, otelSdk OtelSdk) OdigosInstrumentationDevice {
pluginName := InstrumentationPluginName(language, otelSdk)
func InstrumentationDeviceName(language ProgrammingLanguage, otelSdk OtelSdk, libc *LibCType) OdigosInstrumentationDevice {
pluginName := InstrumentationPluginName(language, otelSdk, libc)
return OdigosInstrumentationDevice(OdigosResourceNamespace + "/" + pluginName)
}

Expand Down
71 changes: 67 additions & 4 deletions common/instrumentationdevice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,35 @@ func TestInstrumentationPluginName(t *testing.T) {
SdkType: NativeOtelSdkType,
SdkTier: CommunityOtelSdkTier,
}
pluginName := InstrumentationPluginName(language, otelSdk)
pluginName := InstrumentationPluginName(language, otelSdk, nil)
want := "dotnet-native-community"
if pluginName != want {
t.Errorf("InstrumentationPluginName() = %v, want %v", pluginName, want)
}
}

func TestInstrumentationPluginNameMusl(t *testing.T) {
language := DotNetProgrammingLanguage
otelSdk := OtelSdk{
SdkType: NativeOtelSdkType,
SdkTier: CommunityOtelSdkTier,
}
musl := Musl
pluginName := InstrumentationPluginName(language, otelSdk, &musl)
want := "musl-dotnet-native-community"
if pluginName != want {
t.Errorf("InstrumentationPluginName() = %v, want %v", pluginName, want)
}
}

func TestInstrumentationPluginNameGlib(t *testing.T) {
language := DotNetProgrammingLanguage
otelSdk := OtelSdk{
SdkType: NativeOtelSdkType,
SdkTier: CommunityOtelSdkTier,
}
glib := Glibc
pluginName := InstrumentationPluginName(language, otelSdk, &glib)
want := "dotnet-native-community"
if pluginName != want {
t.Errorf("InstrumentationPluginName() = %v, want %v", pluginName, want)
Expand All @@ -23,21 +51,56 @@ func TestInstrumentationDeviceName(t *testing.T) {
SdkType: EbpfOtelSdkType,
SdkTier: EnterpriseOtelSdkTier,
}
deviceName := InstrumentationDeviceName(language, otelSdk)
deviceName := InstrumentationDeviceName(language, otelSdk, nil)
want := "instrumentation.odigos.io/java-ebpf-enterprise"
if string(deviceName) != want {
t.Errorf("InstrumentationDeviceName() = %v, want %v", deviceName, want)
}
}

func TestInstrumentationDeviceNameToComponents(t *testing.T) {
func TestInstrumentationDeviceNameGlib(t *testing.T) {
language := JavaProgrammingLanguage
otelSdk := OtelSdk{
SdkType: EbpfOtelSdkType,
SdkTier: EnterpriseOtelSdkTier,
}
glib := Glibc
deviceName := InstrumentationDeviceName(language, otelSdk, &glib)
want := "instrumentation.odigos.io/java-ebpf-enterprise"
if string(deviceName) != want {
t.Errorf("InstrumentationDeviceName() = %v, want %v", deviceName, want)
}
}

func TestInstrumentationDeviceNameToComponents(t *testing.T) {
language := GoProgrammingLanguage
otelSdkType := EbpfOtelSdkType
otelSdkTier := CommunityOtelSdkTier
sdk := OtelSdk{SdkType: otelSdkType, SdkTier: otelSdkTier}

deviceName := InstrumentationDeviceName(language, sdk)
deviceName := InstrumentationDeviceName(language, sdk, nil)
gotLanguage, gotSdk := InstrumentationDeviceNameToComponents(string(deviceName))

if gotLanguage != language {
t.Errorf("InstrumentationDeviceNameToComponents() gotLanguage = %v, want %v", gotLanguage, language)
}
if gotSdk.SdkType != otelSdkType {
t.Errorf("InstrumentationDeviceNameToComponents() gotOtelSdkType = %v, want %v", gotSdk.SdkType, otelSdkType)
}
if gotSdk.SdkTier != otelSdkTier {
t.Errorf("InstrumentationDeviceNameToComponents() gotOtelSdkTier = %v, want %v", gotSdk.SdkTier, otelSdkTier)
}
}

func TestInstrumentationDeviceNameToComponentsMusl(t *testing.T) {

language := DotNetProgrammingLanguage
otelSdkType := NativeOtelSdkType
otelSdkTier := CommunityOtelSdkTier
sdk := OtelSdk{SdkType: otelSdkType, SdkTier: otelSdkTier}

musl := Musl
deviceName := InstrumentationDeviceName(language, sdk, &musl)
gotLanguage, gotSdk := InstrumentationDeviceNameToComponents(string(deviceName))

if gotLanguage != language {
Expand Down
9 changes: 9 additions & 0 deletions common/libc_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package common

// +kubebuilder:validation:Enum=glibc;musl
type LibCType string

const (
Glibc LibCType = "glibc"
Musl LibCType = "musl"
)
58 changes: 58 additions & 0 deletions docs/instrumentations/dotnet/dotnet.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
title: ".NET Native Instrumentation"
sidebarTitle: "Native instrumentation"
---

## Supported Versions

The minimal supported version of .NET Framework is **4.6.2**.

The following CPU architectures are supported:
- amd64 (x86_64)
- arm64

## Instrumentation Libraries

The following .NET modules will be auto instrumented by Odigos:

### Application Frameworks

| Framework | Tracing Support | Metrics Support | Notes |
|---------------------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------:|:-----------------------------------------------------------------------------:|----------------------------------------------------------------------------------------------------------|
| [ASP.NET](https://docs.microsoft.com/aspnet/overview) | Yes | Yes | |
| [ASP.NET Core](https://docs.microsoft.com/aspnet/core/introduction-to-aspnet-core?view=aspnetcore-6.0) | Yes | Yes | |

### Databases

| Library | Tracing Support | Metrics Support | Notes |
|----------------------------------------------------------------------------------------------------|-----------------|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Microsoft.Data.SqlClient](https://www.nuget.org/packages/Microsoft.Data.SqlClient) | Yes | | |
| [System.Data.SqlClient](https://www.nuget.org/packages/System.Data.SqlClient) | Yes | | |
| [MySql.Data](https://dev.mysql.com/doc/connector-net/en/connector-net-introduction.html) | Partial | | This is the official [MySQL](https://dev.mysql.com/) library. |
| [MySqlConnector](https://mysqlconnector.net/) | Yes | | Seems to be the [recommended library for MariaDB](https://mariadb.com/kb/en/mysqlconnector-for-ado-net/). |
| [Npgsql](https://www.npgsql.org/) | Yes | | |
| [Microsoft.Data.SqlLite](https://docs.microsoft.com/dotnet/standard/data/sqlite/?tabs=netcore-cli) | | | |
| [MongoDB.Driver](https://www.nuget.org/packages/mongodb.driver) | Yes | | |
| [StackExchange.Redis](https://stackexchange.github.io/StackExchange.Redis/) | Partial | | |
| [Elasticsearch-net](https://github.com/elastic/elasticsearch-net) | Yes | | 8.0.0+ only. |
| [Oracle.ManagedDataAccess.Core](https://www.nuget.org/packages/Oracle.ManagedDataAccess.Core) | Yes | | 23.4.0+ only. |
| [Oracle.ManagedDataAccess](https://www.nuget.org/packages/Oracle.ManagedDataAccess) | Yes | | 23.4.0+ only. |
| [AWSSDK.DynamoDBv2](https://www.nuget.org/packages/AWSSDK.DynamoDBv2) | | | |
| [Microsoft.Azure.Cosmos](https://www.nuget.org/packages/Microsoft.Azure.Cosmos) | | | |

### Inter-process communication (IPC)

| Library | Tracing Support | Metrics Support | Notes |
|-----------------------------------------------------------------------------------|-------------------------------------------------|-----------------|--------------------------------------------------------------------------------------------------------|
| [HttpClient](https://docs.microsoft.com/dotnet/api/system.net.http.httpclient) | Yes | Yes | |
| [HttpWebRequest](https://docs.microsoft.com/dotnet/api/system.net.httpwebrequest) | Yes | Yes | |
| [WCF](https://docs.microsoft.com/dotnet/framework/wcf/whats-wcf) | Yes (Client adn Service side on .NET Framework) | | |
| [CoreWCF](https://github.com/CoreWCF/CoreWCF) | | | |
| [RestSharp](https://restsharp.dev/) | | | This library may be implicitly supported by instrumenting the underlying HttpClient or HttpWebRequest. |
| [gRPC-dotnet](https://github.com/grpc/grpc-dotnet) | Partial | | Client and service support should be added. |
| [GraphQL](https://www.nuget.org/packages/GraphQL/) | Partial | | |
| [GraphQL Client](https://github.com/graphql-dotnet/graphql-client) | | | |
| [RabbitMQ](https://www.nuget.org/packages/RabbitMQ.Client) | Yes | | `RabbitMQ.Client` 7.0.0+ has native support for traces. |
| [Kafka](https://www.nuget.org/packages/Confluent.Kafka) | | | |
| [NServiceBus](https://docs.particular.net/nservicebus/) | Yes | Yes | |
| [MassTransit](https://masstransit-project.com/) | Yes | | |
2 changes: 1 addition & 1 deletion docs/instrumentations/java/java.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "Java Native Instrumentation"
sidebarTitle: "Native instrumentation"
---

<Info> Native Java Instrumentation is currently the default settings of Odigos OS. </Info>
<Info> Native Java Instrumentation is currently the default settings of Odigos open-source version. </Info>

## Supported Versions

Expand Down
6 changes: 6 additions & 0 deletions docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@
"instrumentations/java/java",
"instrumentations/java/ebpf"
]
},
{
"group": ".NET",
"pages": [
"instrumentations/dotnet/dotnet"
]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,11 @@ spec:
- unknown
- ignored
type: string
libCType:
enum:
- glibc
- musl
type: string
otherAgent:
properties:
name:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ spec:
- unknown
- ignored
type: string
libCType:
enum:
- glibc
- musl
type: string
otherAgent:
properties:
name:
Expand Down
Loading

0 comments on commit 01cef4b

Please sign in to comment.