Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vapor Support #130

Open
jdmcd opened this issue Jun 26, 2017 · 11 comments
Open

Vapor Support #130

jdmcd opened this issue Jun 26, 2017 · 11 comments

Comments

@jdmcd
Copy link

jdmcd commented Jun 26, 2017

Hello,

This project looks incredible. Is it possible to use it with a Vapor server? I saw in the article it said that it would automatically setup a Kitura server, but I'd like to use it with Vapor.

Thanks!

@tobespc
Copy link
Member

tobespc commented Jun 27, 2017

@mcdappdev It should be easy to make it work with Vapor. Modifying SwiftMetricsDash.swift should be the place to make any changes. We don't have it in plan to do that right now but if you would like to have a go and submit a pull request, you would be more than welcome.

@seabaylea
Copy link
Member

@tanner0101 @loganwright any views on doing this for Vapor?

@jdmcd
Copy link
Author

jdmcd commented Jun 27, 2017

I'd love to give it a shot!

@jdmcd
Copy link
Author

jdmcd commented Jun 27, 2017

I'm trying to figure out the best way to go about doing this, since the SwiftMetricsDash.swift file relies heavily on Kitura based imports currently. Should it be rewritten to be protocol-based?

@gperdomor
Copy link

@mcdappdev I think the best way is make a fork, because this seems to be integrated to kitura

@seabaylea
Copy link
Member

@mcdappdev @gperdomor we're certainly not against refactoring and providing protocols to make it easier to plug into to other frameworks.

@tanner0101
Copy link

@seabaylea would be awesome if the protocols and kitura implementation were in a separate package. We could then pull in just the protocols for the vapor implementation. lmk what I could do to help with that.

@tobespc
Copy link
Member

tobespc commented Jul 21, 2017

@tanner0101 I'll take a look at refactoring the protocols and Kitura implementation out into separate packages

@loganwright
Copy link

I'm sure you're plenty busy w/ a million other things, but I wanted to check in and see if you've had a chance to take a look yet @tobespc 👍

@MrLotU
Copy link

MrLotU commented Jun 2, 2018

I've created https://github.com/MrLotU/VaporMonitoring based off of SwiftMonitoring and the Kitura parts, but it's working with Vapor (as of posting this, it's still in it's early stages)

@t089
Copy link

t089 commented Nov 16, 2018

Hello, if understand the Package.swift correctly, SwiftMetrics does not have a direct dependency on Kitura. This would make it very lightweight to integrate it into other projects. At the moment, you always have to build Kitura even when you are not using any of the Kitura features.

As a test I changed Package.swift slightly:

let package = Package(
  name: "SwiftMetrics",
  products: [
        .library(
            name: "SwiftMetrics",
            targets: ["SwiftMetrics"]),
        .library(
            name: "SwiftMetricsKitura",
            targets: ["SwiftMetricsKitura",
                "SwiftBAMDC",
                "SwiftMetricsBluemix",
                "SwiftMetricsDash",
                "SwiftMetricsREST",
                "SwiftMetricsPrometheus"]),

        .executable(name: "SwiftMetricsEmitSample", targets: ["SwiftMetricsEmitSample"]),
        .executable(name: "SwiftMetricsCommonSample", targets: ["SwiftMetricsCommonSample"]),
    ],
  dependencies: [
    .package(url: "https://github.com/IBM-Swift/Kitura.git", from: "2.3.0"),
    webSocketPackage,
    .package(url: "https://github.com/IBM-Swift/Swift-cfenv.git", from: "6.0.0"),
    .package(url: "https://github.com/RuntimeTools/omr-agentcore", .exact("3.2.4-swift4")),
  ],
  targets: [
      .target(name: "SwiftMetrics", dependencies: ["agentcore", "hcapiplugin", "envplugin", "cpuplugin", "memplugin", "CloudFoundryEnv"]),
      .target(name: "SwiftMetricsKitura", dependencies: ["SwiftMetrics", "Kitura"]),
      .target(name: "SwiftBAMDC", dependencies: ["SwiftMetricsKitura", "Kitura-WebSocket"]),
      .target(name: "SwiftMetricsBluemix", dependencies: ["SwiftMetricsKitura","SwiftBAMDC"]),
      .target(name: "SwiftMetricsDash", dependencies: ["SwiftMetricsBluemix"]),
      .target(name: "SwiftMetricsREST", dependencies: ["SwiftMetricsKitura"]),
      .target(name: "SwiftMetricsPrometheus", dependencies:["SwiftMetricsKitura"]),
      .target(name: "SwiftMetricsCommonSample", dependencies: ["SwiftMetrics"],
            path: "commonSample/Sources"),
      .target(name: "SwiftMetricsEmitSample", dependencies: ["SwiftMetrics"],
            path: "emitSample/Sources"),
      .testTarget(name: "CoreSwiftMetricsTests", dependencies: ["SwiftMetrics"]),
      .testTarget(name: "SwiftMetricsRESTTests", dependencies: ["SwiftMetricsREST"])
   ]
)

With this change I can use SwiftMetrics but no longer have to build Kitura as well. Would this be an option?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants