Proposal: built-in tracing and metrics via ActivitySource/Meter

Aberta
#1,854 4 comentários 3 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 3 dias

@YoussefElshemi já está trabalhando nisso.

Desde 27/10/2026.

  • #1857 de @YoussefElshemi — aberto

Avaliação

Dificuldade
5/5
Tempo estimado
Mais de uma semana
Facilidade para iniciantes
35/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
csharp
Domínio
observability

Direção de pesquisa

Read the working prototype linked in the issue and inspect the existing Internal* methods it hooks into. The proposal covers tracing for connections, SFTP operations, and command execution, plus an operation duration metric; existing unit tests and integration tests are reported passing. Before implementation, resolve the dependency, attribute naming, command secrecy, and first PR scope questions; done means the agreed telemetry scope is covered and verified.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Hi, I'd like to propose adding built-in tracing and metrics to SSH.NET using System.Diagnostics.ActivitySource and Meter, the same approach Npgsql and the MongoDB driver use.

I first opened an OpenTelemetry contrib package that wraps ISftpClient/ISshClient (https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/5781). An OTel maintainer suggested building it into the library instead, so users only need AddSource("Renci.SshNet") and AddMeter("Renci.SshNet"). That also works with other backends (Datadog, App Insights), and covers cases a wrapper can't reach: CreateCommand + Execute, Begin*/End*, non-seekable streams.

I have a working prototype: https://github.com/YoussefElshemi/SSH.NET/tree/native-telemetry

  • Spans:
    • Connect (ssh/sftp/scp/netconf)
    • SFTP UploadFile, DownloadFile, ListDirectory
    • SshCommand execution
  • Metric: ssh.client.operation.duration histogram (seconds)
  • Where it hooks in: the existing Internal* methods, so every overload is covered
  • When nobody is listening: no allocation or extra work
  • Tests: existing unit tests pass. New integration tests pass on net48/net8/net9/net10.

Questions before I go further:

  1. It adds System.Diagnostics.DiagnosticSource (8.0.1) as a dependency on net462/netstandard2.0 only. Is that acceptable?
  2. Attribute names like ssh.operation.name, sftp.transfer.bytes and ssh.command.exit_code aren't official OpenTelemetry names yet. Any preference?
  3. Command text isn't recorded, since it may contain secrets. Should there be an opt-in?
  4. Should a first PR stay this small, or also cover Exists/Delete/Rename/SCP?

Would you be open to a PR along these lines?

Linguagem predominante
C#
Estrelas
4.4k
Forks
987
Merge médio
2d 6h
PRs com merge (30d)
4

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de sshnet/SSH.NET

Todas as issues de sshnet/SSH.NET

Issues semelhantes

Mais issues de C#

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.