Skip to content
Draft
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
33 changes: 33 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
services:
seq:
profiles:
- seq
image: datalust/seq
ports:
- 5341:80 # http and collection
environment:
- ACCEPT_EULA=Y
# http://localhost:5341
# OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:5341/ingest/otlp/v1/logs
# OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"
# OTEL_EXPORTER_OTLP_HEADERS="X-Seq-ApiKey=your_api_key"
jaeger:
profiles:
- jaeger
image: jaegertracing/all-in-one
Copy link
Contributor

Choose a reason for hiding this comment

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

OMG travesty - not using the Aspire Dashboard? 😱

ports:
- 6831:6831/udp
- 6832:6832/udp
- 5778:5778
- 16686:16686
- 4317:4317
- 4318:4318
- 14250:14250
- 14268:14268
- 14269:14269
- 9411:9411
environment:
- COLLECTOR_ZIPKIN_HTTP_PORT=9411
- COLLECTOR_OTLP_ENABLED=true
# http://localhost:16686/
# OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
41 changes: 28 additions & 13 deletions src/FsAutoComplete.Core/CompilerServiceInterface.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace FsAutoComplete

open FsAutoComplete.Utils.Tracing
open FsAutoComplete.Telemetry
open System.IO
open FSharp.Compiler.CodeAnalysis
open Utils
Expand All @@ -14,6 +16,7 @@ open System
open FsToolkit.ErrorHandling
open FSharp.Compiler.CodeAnalysis.ProjectSnapshot
open System.Threading
open IcedTasks

type Version = int

Expand Down Expand Up @@ -95,6 +98,8 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize, parallelRefe
useTransparentCompiler = useTransparentCompiler
)

let thisType = typeof<FSharpCompilerServiceChecker>

let entityCache = EntityCache()

// FCS can't seem to handle parallel project restores for script files
Expand Down Expand Up @@ -323,15 +328,18 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize, parallelRefe
}

member self.GetProjectSnapshotsFromScript(file: string<LocalPath>, source, tfm: FSIRefs.TFM) =
async {
try
do! scriptLocker.WaitAsync() |> Async.AwaitTask
asyncEx {
let tags = seq {
yield "file", box file
yield "tfm", tfm
}
use _trace = Tracing.fsacActivitySource.StartActivityForType(thisType, tags = tags)
use! _l = scriptLocker.LockAsync()

match tfm with
| FSIRefs.TFM.NetFx -> return! self.GetNetFxScriptSnapshot(file, source)
| FSIRefs.TFM.NetCore -> return! self.GetNetCoreScriptSnapshot(file, source)
finally
scriptLocker.Release() |> ignore<int>

}


Expand Down Expand Up @@ -404,15 +412,17 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize, parallelRefe
}

member self.GetProjectOptionsFromScript(file: string<LocalPath>, source, tfm) =
async {
try
do! scriptLocker.WaitAsync() |> Async.AwaitTask
asyncEx {
let tags = seq {
yield "file", box file
yield "tfm", box tfm
}
use _trace = Tracing.fsacActivitySource.StartActivityForType(thisType, tags = tags)
use! _l = scriptLocker.LockAsync()

match tfm with
| FSIRefs.TFM.NetFx -> return! self.GetNetFxScriptOptions(file, source)
| FSIRefs.TFM.NetCore -> return! self.GetNetCoreScriptOptions(file, source)
finally
scriptLocker.Release() |> ignore<int>
}


Expand Down Expand Up @@ -504,7 +514,9 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize, parallelRefe
.SetSize(1)
.SetSlidingExpiration(TimeSpan.FromMinutes(5.))

return lastCheckResults.Set(filePath, r, ops)
let rw = WeakReference<ParseAndCheckResults>(r)
lastCheckResults.Set(filePath, rw, ops) |> ignore
return r
else
return r
with ex ->
Expand Down Expand Up @@ -582,8 +594,11 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize, parallelRefe

checkerLogger.info (Log.setMessage "{opName}" >> Log.addContextDestructured "opName" opName)

match lastCheckResults.TryGetValue<ParseAndCheckResults>(file) with
| (true, v) -> Some v
match lastCheckResults.TryGetValue<WeakReference<ParseAndCheckResults>>(file) with
| (true, v) ->
match v.TryGetTarget() with
| (true, v) -> Some v
| _ -> None
| _ -> None

member _.TryGetRecentCheckResultsForFile(file: string<LocalPath>, snapshot: FSharpProjectSnapshot) =
Expand Down
11 changes: 7 additions & 4 deletions src/FsAutoComplete.Logging/FsOpenTelemetry.fs
Original file line number Diff line number Diff line change
Expand Up @@ -576,13 +576,15 @@ type ActivityExtensions =

let tags =
ActivityTagsCollection(
[ yield KeyValuePair(SemanticConventions.General.Exceptions.exception_escaped, box escaped)
seq {
yield KeyValuePair(SemanticConventions.General.Exceptions.exception_escaped, box escaped)
yield KeyValuePair(SemanticConventions.General.Exceptions.exception_type, box errorType)

if Option.isSome stacktrace then
yield KeyValuePair(SemanticConventions.General.Exceptions.exception_stacktrace, box stacktrace.Value)

yield KeyValuePair(SemanticConventions.General.Exceptions.exception_message, box errorMessage) ]
yield KeyValuePair(SemanticConventions.General.Exceptions.exception_message, box errorMessage)
}
)

ActivityEvent(SemanticConventions.General.Exceptions.exception_, tags = tags)
Expand All @@ -604,11 +606,12 @@ type ActivityExtensions =

let tags =
ActivityTagsCollection(
[ yield KeyValuePair(SemanticConventions.General.Exceptions.exception_escaped, box escaped)
seq {
yield KeyValuePair(SemanticConventions.General.Exceptions.exception_escaped, box escaped)
yield KeyValuePair(SemanticConventions.General.Exceptions.exception_type, box exceptionType)
yield KeyValuePair(SemanticConventions.General.Exceptions.exception_stacktrace, box exceptionStackTrace)
if not <| String.IsNullOrEmpty(exceptionMessage) then
yield KeyValuePair(SemanticConventions.General.Exceptions.exception_message, box exceptionMessage) ]
yield KeyValuePair(SemanticConventions.General.Exceptions.exception_message, box exceptionMessage) }
)

ActivityEvent(SemanticConventions.General.Exceptions.exception_, tags = tags)
Expand Down
29 changes: 28 additions & 1 deletion src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ module ArrayHelpers =

open ArrayHelpers

// type DiagnosticType =
// | FSharp of FSharp.Compiler.Diagnostics.FSharpDiagnostic
// | Analyzer of FSharp.Analyzers.SDK.Message
// | UnusedOpen

type AdaptiveFSharpLspServer
(
workspaceLoader: IWorkspaceLoader,
Expand Down Expand Up @@ -2248,7 +2253,29 @@ type AdaptiveFSharpLspServer

override x.TextDocumentDeclaration p = x.logUnimplementedRequest p

override x.TextDocumentDiagnostic p = x.logUnimplementedRequest p
override x.TextDocumentDiagnostic p = asyncResult {
let tags = [ "DocumentDiagnosticParams", box p ]
use trace = fsacActivitySource.StartActivityForType(thisType, tags = tags)
try
logger.info (
Log.setMessage "TextDocumentDiagnostic Request: {params}"
>> Log.addContextDestructured "params" p
)
let filePath = p.TextDocument.GetFilePath() |> Utils.normalizePath

let! diags = state.GetDiagnostics filePath |> AsyncResult.ofStringErr

return DocumentDiagnosticReport.C1 ({ Kind = "full"; ResultId = None; Items = diags; RelatedDocuments = None })

with e ->
trace |> Tracing.recordException e

let logCfg =
Log.setMessage "TextDocumentDiagnostic Request Errored {p}"
>> Log.addContextDestructured "p" p

return! returnException e logCfg
}

override x.TextDocumentLinkedEditingRange p = x.logUnimplementedRequest p

Expand Down
Loading
Loading